package net.mikoo.seals.api.model.company;

import java.util.ArrayList;
import java.util.List;

import net.mikoo.seals.api.model.BaseResponse;
import net.mikoo.seals.model.Company;

public class CompanyListResponse extends BaseResponse {

	private static final long serialVersionUID = -885408275430655696L;

	private List<CompanyInfo> companyList;

	public List<CompanyInfo> getCompanyList() {
		return companyList;
	}

	public void setCompanyList(List<CompanyInfo> companyList) {
		this.companyList = companyList;
	}
	
	public static CompanyListResponse valueOf(List<Company> companyList) {
		CompanyListResponse result = new CompanyListResponse();
		
		if(companyList == null) {
			return result;
		}
		List<CompanyInfo> companyInfoList = new ArrayList<CompanyInfo>();
		for(Company company : companyList) {
			if(company == null) {
				continue;
			}
			CompanyInfo companyInfo = new CompanyInfo();
			companyInfo.setCompanyId(company.getCompanyId());
			companyInfo.setCompanyName(company.getCompanyName());
			companyInfoList.add(companyInfo);
		}
		result.setCompanyList(companyInfoList);
		return result;
	}
	
}
